package cn.the.angry.model;

import java.awt.image.BufferedImage;

import org.jbox2d.collision.shapes.CircleDef;
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.dynamics.World;

import cn.the.angry.physics.AngryCircle;

public class CircleBaseElement extends Actor {
	protected AngryCircle circle;
	protected float radius;

	public CircleBaseElement(BufferedImage[] frames) {
		super(frames, true);
	}
	
	public CircleBaseElement(BufferedImage[] frames, final int hp) {
		super(frames, hp);
	}
	
	public CircleBaseElement(BufferedImage[] frames, final boolean canDie) {
		super(frames, canDie);
	}
	
	public CircleDef getCircleDef(){
		return circle.getCircleDef();
	}

	public void create(World world, float _x, float _y, float _density, float _friction
			   , float _restitution, float _radius){
		radius = _radius;
		circle = new AngryCircle(world, _x, _y, _density, _friction, _restitution, _radius, this);
		setBinding(true);
		setWorld(world);
	}
		
	@Override
	public void bind() {
		getSprite().setAttributes(circle.getPosition().x-radius, circle.getPosition().y-radius, circle.getBody().getAngle());
	}
	
	
	@Override
	public Body getBody() {
		return circle.getBody();
	}

	@Override
	public BodyDef getBodyDef() {
		return circle.getBodyDef();
	}
	
	
}
